-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Report FQDN on host.name as opt-in, enabled by feature flag #2218
Conversation
This pull request does not have a backport label. Could you fix it @AndersonQ? 🙏
NOTE: |
2d9504f
to
1312b91
Compare
This pull request is now in conflicts. Could you fix it? 🙏
|
1 similar comment
This pull request is now in conflicts. Could you fix it? 🙏
|
b8eb1a0
to
8dc9168
Compare
🌐 Coverage report
|
da06543
to
e705893
Compare
14d3937
to
47d0bdb
Compare
c43edb0
to
51fb6a5
Compare
This pull request is now in conflicts. Could you fix it? 🙏
|
I'm starting to look at this PR now. For starters, I'm just going to clean it up a bit like so:
|
Cleanup PR is up: #2361. Once it's merged, I'll rebase this PR here on |
895d73f
to
01d4a96
Compare
Even after #2361, there are still some changes left in this PR here (accounting for nearly 50% LOC) that aren't directly related to implementing the FQDN feature. They are related to refactoring the fake component and shipper. To make this PR here even easier to review, I've extracted these refactoring changes into it's own smaller PR: #2378. Once that PR is reviewed and merged, I'll rebase this PR here on |
This pull request is now in conflicts. Could you fix it? 🙏
|
fa47fec
to
a39e14e
Compare
7f2d220
to
ef24d66
Compare
@ycombinator Looks like we are good to know with this PR now right? 😄 |
No, still one issue remaining: #2218 (comment). I'm still trying to figure this out myself but have also pinged @cmacknz and @blakerouse (in Slack) for help. |
@@ -199,6 +201,16 @@ func (i *AgentInfo) ECSMetadataFlatMap() (map[string]interface{}, error) { | |||
} | |||
|
|||
info := sysInfo.Info() | |||
hostname := info.Hostname | |||
l.Debugf("in ECSMetadataFlatMap, hostname = %s", hostname) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only added this line for debugging purposes, so we could see debug-level logs from this method regardless of whether the FQDN feature flag was set or not. Will remove before this PR is merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgot to remove this line in my excitement to merge this PR, so here's the follow up PR to remove it: #2451
sysInfo, err := sysinfo.Host() | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
info := sysInfo.Info() | ||
hostname := info.Hostname | ||
l.Debugf("in ECSMetadata, hostname = %s", hostname) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only added this line for debugging purposes, so we could see debug-level logs from this method regardless of whether the FQDN feature flag was set or not. Will remove before this PR is merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgot to remove this line in my excitement to merge this PR, so here's the follow up PR to remove it: #2451
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the remaining issue with the log level was not introduced in this PR. Shaunak is going to file an issue to track the problem.
With that out of the way this looks good to me. Thanks for all the effort here!
* wip * wip * wip * clean up * wip * . * agent.name as fqdn * it works * wip * WIP - using fake input, created test, it seems to work * finish test for feature flags * remove debug log * some clean up * mage check * fixing licenses * it works * it works * remove debug logs and comments * make notice * fake component and shipper are built by TestMain * fixing tests * make notice * adjust tests * update elatic-agent-client * add .exe for win binaries * adjust fake components build * increase test timeout * fix tests * adjust features pkg and don't send featuresFlag if nil * it works * make notice * revert some changes * handle error properly * add TODO * Set FQDN for Vagrant elastic-agent VM Useful for testing FQDN feature; harmless otherwise * Undoing trivial formatting changes * Running mage fmt * Remove personal repo from NOTICE overrides * Sorting imports * Fix error handling * Fixing access * Fixing packaging of fake component * Update logging * Refactoring fake component * Allowing fmt.Print* in TestMain * Remove redundant return * Fixing typo in error message * Undo unintentional changes * Removing redundant TestMain file * Add comment on FQDN to Vagrantfile * Remove debug logging statements * Making test pass * Document feature flags configuration in reference config file * Adding CHANGELOG entry * Use convenience method * Formatting * Use convenience method from elastic-agent-libs * Running mage update * Fixing imports * Reducing whitespace changes * Reducing whitespace changes * Reducing whitespace changes * Reducing whitespace changes * Restore timeout duration * Move mutex inside struct * Prevent mutex copying * Fixing state diagnostics test * Fixing components diagnostics test * Adding features.source to components golden file * More interesting diagnostics state test * Log error if FQDN lookup fails and fallback to OS-reported hostname * Bump up go-sysinfo dependency version * Fix typos * Fixing compile errors * Fix tests * Fix imports * Fix issues lost in rebase * Fixing more imports * Updating NOTICE.txt * Clarify features indentation * Remove replace directive * Bumping up version on elastic-agent-client dependency * Adding test mocking DNS * Initialize featuresIdx in same place as units' configIdx * Updating NOTICE.txt * Remove unnecessary nil check * Set features in state initially * Update features in state from checkin observed message * Remove TODO * Updating elatic-agent.yml test fixture to enable FQDN feature flag * Try flipping the authoritative flag * Remove unreliable DNS mocking test * Set source * Update test fixture * Change logger * Fixing test case * Omit feature flags serialization from state.yaml diag file * Updating NOTICE.txt * Add descriptive comment on why Features is not being serialized as YAML * Updating test fixture * Inject logger into metadata methods --------- Co-authored-by: Shaunak Kashyap <[email protected]> (cherry picked from commit be818cc) # Conflicts: # internal/pkg/agent/application/application.go # internal/pkg/agent/application/coordinator/coordinator.go # internal/pkg/agent/application/coordinator/testdata/simple_config/expected/state.yaml
* wip * wip * wip * clean up * wip * . * agent.name as fqdn * it works * wip * WIP - using fake input, created test, it seems to work * finish test for feature flags * remove debug log * some clean up * mage check * fixing licenses * it works * it works * remove debug logs and comments * make notice * fake component and shipper are built by TestMain * fixing tests * make notice * adjust tests * update elatic-agent-client * add .exe for win binaries * adjust fake components build * increase test timeout * fix tests * adjust features pkg and don't send featuresFlag if nil * it works * make notice * revert some changes * handle error properly * add TODO * Set FQDN for Vagrant elastic-agent VM Useful for testing FQDN feature; harmless otherwise * Undoing trivial formatting changes * Running mage fmt * Remove personal repo from NOTICE overrides * Sorting imports * Fix error handling * Fixing access * Fixing packaging of fake component * Update logging * Refactoring fake component * Allowing fmt.Print* in TestMain * Remove redundant return * Fixing typo in error message * Undo unintentional changes * Removing redundant TestMain file * Add comment on FQDN to Vagrantfile * Remove debug logging statements * Making test pass * Document feature flags configuration in reference config file * Adding CHANGELOG entry * Use convenience method * Formatting * Use convenience method from elastic-agent-libs * Running mage update * Fixing imports * Reducing whitespace changes * Reducing whitespace changes * Reducing whitespace changes * Reducing whitespace changes * Restore timeout duration * Move mutex inside struct * Prevent mutex copying * Fixing state diagnostics test * Fixing components diagnostics test * Adding features.source to components golden file * More interesting diagnostics state test * Log error if FQDN lookup fails and fallback to OS-reported hostname * Bump up go-sysinfo dependency version * Fix typos * Fixing compile errors * Fix tests * Fix imports * Fix issues lost in rebase * Fixing more imports * Updating NOTICE.txt * Clarify features indentation * Remove replace directive * Bumping up version on elastic-agent-client dependency * Adding test mocking DNS * Initialize featuresIdx in same place as units' configIdx * Updating NOTICE.txt * Remove unnecessary nil check * Set features in state initially * Update features in state from checkin observed message * Remove TODO * Updating elatic-agent.yml test fixture to enable FQDN feature flag * Try flipping the authoritative flag * Remove unreliable DNS mocking test * Set source * Update test fixture * Change logger * Fixing test case * Omit feature flags serialization from state.yaml diag file * Updating NOTICE.txt * Add descriptive comment on why Features is not being serialized as YAML * Updating test fixture * Inject logger into metadata methods --------- Co-authored-by: Shaunak Kashyap <[email protected]> (cherry picked from commit be818cc)
* wip * wip * wip * clean up * wip * . * agent.name as fqdn * it works * wip * WIP - using fake input, created test, it seems to work * finish test for feature flags * remove debug log * some clean up * mage check * fixing licenses * it works * it works * remove debug logs and comments * make notice * fake component and shipper are built by TestMain * fixing tests * make notice * adjust tests * update elatic-agent-client * add .exe for win binaries * adjust fake components build * increase test timeout * fix tests * adjust features pkg and don't send featuresFlag if nil * it works * make notice * revert some changes * handle error properly * add TODO * Set FQDN for Vagrant elastic-agent VM Useful for testing FQDN feature; harmless otherwise * Undoing trivial formatting changes * Running mage fmt * Remove personal repo from NOTICE overrides * Sorting imports * Fix error handling * Fixing access * Fixing packaging of fake component * Update logging * Refactoring fake component * Allowing fmt.Print* in TestMain * Remove redundant return * Fixing typo in error message * Undo unintentional changes * Removing redundant TestMain file * Add comment on FQDN to Vagrantfile * Remove debug logging statements * Making test pass * Document feature flags configuration in reference config file * Adding CHANGELOG entry * Use convenience method * Formatting * Use convenience method from elastic-agent-libs * Running mage update * Fixing imports * Reducing whitespace changes * Reducing whitespace changes * Reducing whitespace changes * Reducing whitespace changes * Restore timeout duration * Move mutex inside struct * Prevent mutex copying * Fixing state diagnostics test * Fixing components diagnostics test * Adding features.source to components golden file * More interesting diagnostics state test * Log error if FQDN lookup fails and fallback to OS-reported hostname * Bump up go-sysinfo dependency version * Fix typos * Fixing compile errors * Fix tests * Fix imports * Fix issues lost in rebase * Fixing more imports * Updating NOTICE.txt * Clarify features indentation * Remove replace directive * Bumping up version on elastic-agent-client dependency * Adding test mocking DNS * Initialize featuresIdx in same place as units' configIdx * Updating NOTICE.txt * Remove unnecessary nil check * Set features in state initially * Update features in state from checkin observed message * Remove TODO * Updating elatic-agent.yml test fixture to enable FQDN feature flag * Try flipping the authoritative flag * Remove unreliable DNS mocking test * Set source * Update test fixture * Change logger * Fixing test case * Omit feature flags serialization from state.yaml diag file * Updating NOTICE.txt * Add descriptive comment on why Features is not being serialized as YAML * Updating test fixture * Inject logger into metadata methods --------- Co-authored-by: Shaunak Kashyap <[email protected]> (cherry picked from commit be818cc)
…feature flag (#2449) * Report FQDN on host.name as opt-in, enabled by feature flag (#2218) * wip * wip * wip * clean up * wip * . * agent.name as fqdn * it works * wip * WIP - using fake input, created test, it seems to work * finish test for feature flags * remove debug log * some clean up * mage check * fixing licenses * it works * it works * remove debug logs and comments * make notice * fake component and shipper are built by TestMain * fixing tests * make notice * adjust tests * update elatic-agent-client * add .exe for win binaries * adjust fake components build * increase test timeout * fix tests * adjust features pkg and don't send featuresFlag if nil * it works * make notice * revert some changes * handle error properly * add TODO * Set FQDN for Vagrant elastic-agent VM Useful for testing FQDN feature; harmless otherwise * Undoing trivial formatting changes * Running mage fmt * Remove personal repo from NOTICE overrides * Sorting imports * Fix error handling * Fixing access * Fixing packaging of fake component * Update logging * Refactoring fake component * Allowing fmt.Print* in TestMain * Remove redundant return * Fixing typo in error message * Undo unintentional changes * Removing redundant TestMain file * Add comment on FQDN to Vagrantfile * Remove debug logging statements * Making test pass * Document feature flags configuration in reference config file * Adding CHANGELOG entry * Use convenience method * Formatting * Use convenience method from elastic-agent-libs * Running mage update * Fixing imports * Reducing whitespace changes * Reducing whitespace changes * Reducing whitespace changes * Reducing whitespace changes * Restore timeout duration * Move mutex inside struct * Prevent mutex copying * Fixing state diagnostics test * Fixing components diagnostics test * Adding features.source to components golden file * More interesting diagnostics state test * Log error if FQDN lookup fails and fallback to OS-reported hostname * Bump up go-sysinfo dependency version * Fix typos * Fixing compile errors * Fix tests * Fix imports * Fix issues lost in rebase * Fixing more imports * Updating NOTICE.txt * Clarify features indentation * Remove replace directive * Bumping up version on elastic-agent-client dependency * Adding test mocking DNS * Initialize featuresIdx in same place as units' configIdx * Updating NOTICE.txt * Remove unnecessary nil check * Set features in state initially * Update features in state from checkin observed message * Remove TODO * Updating elatic-agent.yml test fixture to enable FQDN feature flag * Try flipping the authoritative flag * Remove unreliable DNS mocking test * Set source * Update test fixture * Change logger * Fixing test case * Omit feature flags serialization from state.yaml diag file * Updating NOTICE.txt * Add descriptive comment on why Features is not being serialized as YAML * Updating test fixture * Inject logger into metadata methods --------- Co-authored-by: Shaunak Kashyap <[email protected]> (cherry picked from commit be818cc) * Fixing return args --------- Co-authored-by: Anderson Queiroz <[email protected]> Co-authored-by: Shaunak Kashyap <[email protected]>
What does this PR do?
This PR enhances Elastic Agent to understand feature flags configuration, supplied either via standalone policy or Fleet policy, and applies said configuration to itself as well as to its components.
Why is it important?
To implement the first feature flag, FQDN. Enabling the FQDN feature flag will allow Agent and its components to report their host's fully-qualified domain name via the
host.name
field in events generated by the components.Checklist
./changelog/fragments
using the changelog toolAuthor's Checklist
Manual testing of Agent in Standalone mode
Without FQDN feature flag enabled
agent_standalone_fqdn_disabled.mov
With FQDN feature flag enabled
agent_standalone_fqdn_enabled.mov
How to test this PR locally
The screen recordings in the section above were created by following the same steps as listed below.
foo.bar.baz
.host.name
andhost.hostname
are both set to the short hostname, e.g.foo
in all documents.host.name
is set to the FQDN, e.g.foo.bar.baz
whilehost.hostname
is set to the short hostname, e.g.foo
, in all documents.Related issues
host.name
enabled by a feature flag #2185Use cases
Screenshots
Logs